package org.smarthings.things.automation.rest;

import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.QueryParam;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.Response;

import org.smarthings.things.automation.rest.resources.RuleColleactionResource;
import org.smarthings.things.automation.rest.resources.RuleResource;
import org.smarthings.things.commons.rest.VersionResource;

@Path("rules")
public interface RemoteRulesManagement {

	@GET
	@Path("version")
	VersionResource getVersion() throws WebApplicationException;

	// TODO consider returning only a discovery style list, e.g. only href fields included
	// TODO this concept may be achieved by additional http header or query parameter
	// TODO handle pagination via query parameter or http header

	@GET
	RuleColleactionResource getRules(@QueryParam("filter") String filter)
			throws WebApplicationException;

	@POST
	Response registerRule(RuleResource rule) throws WebApplicationException;

	@PUT
	@Path("{ruleUUID}")
	RuleResource updateRule(@PathParam("ruleUUID") String ruleUUID, RuleResource rule)
			throws WebApplicationException;

	@GET
	@Path("{ruleUUID}")
	RuleResource getRule(@PathParam("ruleUUID") String ruleUUIDs) throws WebApplicationException;

	@DELETE
	@Path("{ruleUUID}")
	Response unregisterRule(@PathParam("ruleUUID") String ruleUUIDs) throws WebApplicationException;

}
